package com.lhb.mapper;

import com.github.pagehelper.Page;
import com.lhb.dto.CourseAddDTO;
import com.lhb.dto.CourseEditDTO;
import com.lhb.dto.CoursePageQueryDTO;
import com.lhb.vo.CoursePageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CourseMapper {

    /**
     * 分页查询
     * @param coursePageQueryDTO
     * @return
     */
    Page<CoursePageQueryVO> pageQuery(CoursePageQueryDTO coursePageQueryDTO);

    /**
     * 添加课程成绩
     * @param courseAddDTO
     */
    @Insert("insert into course( course_name, course_score, student_id) values (#{courseName},#{courseScore},#{studentId}) ")
    void add(CourseAddDTO courseAddDTO);

    /**
     * 修改课程成绩
     * @param courseEditDTO
     */
    @Update("update course set course_score=#{courseScore} where student_id=#{studentId} and course_name=#{courseName}")
    void edit(CourseEditDTO courseEditDTO);

    @Delete("delete from course where id=#{id} ")
    void delete(Long id);
}
